package frsf.cidisi.exercise.laberinto.search;

import frsf.cidisi.exercise.laberinto.search.util.Par;
import frsf.cidisi.faia.solver.search.IEstimatedCostFunction;
import frsf.cidisi.faia.solver.search.NTree;

/**
 * This class allows to define a function to be used by any
 * informed search strategy, like A Star or Greedy.
 */
public class Heuristic implements IEstimatedCostFunction {

	private Par objetivo;
	
	
    public Heuristic(Par objetivo) {
		super();
		this.objetivo = objetivo;
	}


	/**
     * It returns the estimated cost to reach the goal from a NTree node.
     */
    @Override
    public double getEstimatedCost(NTree node) {
    	EstadoAgente e = (EstadoAgente) node.getAgentState();
        
        return e.getPosicion().medir(objetivo);
    }
}
